
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;

public class Contrato37E {

     public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/dat_4_1_2013","root","ing.central");
            
            JasperReport reporte = (JasperReport) JRLoader.loadObject("c://Reporte//Contrato37.jasper");
            
            HashMap parametros = new HashMap();
            
            parametros.put("pCod_estu","cod_estu=13290");
            
            JasperPrint jasperPrint = JasperFillManager.fillReport(reporte,parametros,conexion);
            
            JRExporter exporter = new JRPdfExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
            
            File miFile = new File("c://Reporte//contrato37.pdf");
            
            exporter.setParameter(JRExporterParameter.OUTPUT_FILE,miFile);
            
            exporter.exportReport();
            
        } catch (JRException ex) {
            Logger.getLogger(Contrato37E.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Contrato37E.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Contrato37E.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
